#! /bin/bash

SUR_MOUNT_CONF=/etc/sur.conf
SUR_MOUNT_POINT=/mnt/hs

# Create mount point if not exist
[ -d $SUR_MOUNT_POINT ] || mkdir $SUR_MOUNT_POINT

# Mount hybrid storage 
count=0
while [  $count -lt 20 ]; do
    umount /mnt/hs
    sur_mount config=$SUR_MOUNT_CONF $SUR_MOUNT_POINT
    ls /mnt/hs 2>&1 > /dev/null

    ret=$?
    if [ "$ret" == "0" ]; then
        echo "Mount hybrid storage successfully!"
        exit 0
    fi

    # Sleep 1 second, and retry
    sleep 1
    echo "Failed to mount hybrid storage, retry later..."
    let count=count+1 
done

echo "Oops, failed to mount hybrid storage."
